package bat.ke.qq.com.service.impl;

import bat.ke.qq.com.service.AccountService;
import bat.ke.qq.com.service.UserSerivce;
import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import sun.awt.AppContext;
import sun.awt.geom.AreaOp;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 源码学院-Fox
 * 只为培养BAT程序员而生
 * http://bat.ke.qq.com
 * 往期视频加群:516212256 暗号:6
 */
@Service
public class UserSerivceImpl implements UserSerivce {


    @Autowired
    AccountService accountService;
    @Autowired
    JdbcTemplate jdbcTemplate;

    @Autowired
    UserSerivce userSerivce;

    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public void createUser(String name) throws Exception {
        // 插入user 记录
        jdbcTemplate.update("INSERT INTO `user` (name) VALUES(?)", name);

        // 调用 accountService 添加帐户
        accountService.addAccount(name, 100);

       // int i=1/0;

    }




}
